package com.jml.springsecurity.dto;

import com.fasterxml.jackson.annotation.JsonView;
import com.jml.springsecurity.validator.MyConstraint;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
import javax.validation.constraints.Past;
import org.hibernate.validator.constraints.NotBlank;


public class User {

	//1.使用接口声明多个视图
	public interface UserSimpleView{};
	public interface UserDetailView extends UserSimpleView{};

	private String id;


	@MyConstraint(message = "这是一个自定义注解测试")
	private String username;

	@NotBlank(message = "密码不能为空")
	private String password;

	@Past(message = "生日必须是过去的时间")
	private Date birthday;

	public String getId() {
		return id;
	}

	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public void setId(String id) {
		this.id = id;
	}

	//2.在值对象的get方法上指定视图
	//表示username这个字段是在UserSimpleView接口的视图中展示
	@JsonView(UserSimpleView.class)
	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	//在展示UserDetailView视图时，同时会把UserSimpleView中的视图展示出来，因为为继承关系
	@JsonView(UserDetailView.class)
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
}
